//
//  HomeViewController.m
//  OrderSys
//
//  Created by JM on 15-9-26.
//  Copyright (c) 2015年 zjlskj. All rights reserved.
//

#import "HomeViewController.h"
#import "LoginViewCtrl.h"
#import "QiangdanSearchConditionVC.h"

#define kTotalCol 2;
@interface HomeViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scollView;
@property (nonatomic, strong) UIView *appView;
@property (nonatomic, strong) NSArray *arrayList;

@end

@implementation HomeViewController
- (NSArray *)arrayList{
    if(_arrayList ==nil){
        //字典转模型
        NSArray *array  = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"homeBtnList.plist" ofType:nil]];
        NSMutableArray *arrayM = [NSMutableArray array];
        for (NSDictionary *dict in array){
            [arrayM addObject:dict];
        }
        _arrayList = arrayM;
    }
    return _arrayList;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //self.view.layer.borderColor =
    // Do any additional setup after loading the view.
    CGFloat h = CGRectGetMaxY(self.menuView.frame)+10;
    self.scollView.contentSize = CGSizeMake(self.scollView.frame.size.width,h);
    
//    //取消弹簧效果
////    self.scollView.bounces = NO;
//    //不显示水平滚动标示
//    self.scollView.showsHorizontalScrollIndicator = NO;
//    //不显示垂直滚动标示
////    self.scollView.showsVerticalScrollIndicator = NO;
//    self.scollView.backgroundColor = [UIColor grayColor];
//    CGFloat scollViewH = self.scollView.bounds.size.height - 113;
//    CGFloat headViewH = 160;
//    CGFloat viewW = self.scollView.bounds.size.width;
//    UIView *headView = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, viewW, headViewH)];
//    headView.backgroundColor = [UIColor yellowColor];
//    [self.scollView addSubview:headView];
//    
//    UIView *iconView = [[UIView alloc] init];
//    iconView.center = headView.center;
//    iconView.bounds = CGRectMake(0, 0, 150, 150);
//    iconView.backgroundColor = [UIColor blueColor];
//    [self.scollView addSubview:iconView];
//    
//    CGFloat appViewH = (scollViewH - headViewH)/3;
//    CGFloat appViewW = viewW*0.5;
//    
//    for (int i =0; i < self.arrayList.count;i++){
//        NSDictionary *dict = self.arrayList[i];
//        //行
//        int row = i/kTotalCol;
//        //列
//        int col = i%kTotalCol;
//        
//        int x = col * appViewW;
//        int y = row * appViewH + CGRectGetMaxY(headView.frame);
//        if(x == 0){
//            if(i == 4){
//                self.appView = [[UIView alloc]initWithFrame:CGRectMake(x ,y ,appViewW-1, appViewH)];
//            }else{
//                self.appView = [[UIView alloc]initWithFrame:CGRectMake(x ,y ,appViewW-1, appViewH-1)];
//            }
//        }else if(i >= 0 && i < 4){
//            self.appView = [[UIView alloc]initWithFrame:CGRectMake(x ,y ,appViewW, appViewH-1)];
//        }else{
//            self.appView = [[UIView alloc]initWithFrame:CGRectMake(x ,y ,appViewW, appViewH)];
//        }
//        self.appView.backgroundColor = [UIColor whiteColor];
//        [self.scollView addSubview:self.appView];
//      
//            UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, appViewW, appViewH)];
//            [btn setTitle:dict[@"name"] forState:UIControlStateNormal];
//            btn.titleLabel.font = [UIFont systemFontOfSize:17.0];
//            [btn setTitleColor:[UIColor colorWithRed:20/255.0 green:155/255.0 blue:240/255.0 alpha:1.0] forState:UIControlStateNormal];
//            [self.appView addSubview:btn];
//            
//        
//        
//    }
    
    [LoginViewCtrl presentInViewCtrl:self withSucessHandle:^{
        NSLog(@"登录成功，如果不需要处理，不用实现");
    } animal:YES];
}

//点击我要抢单
- (IBAction)clickBtnQiangDan:(id)sender {
    QiangdanSearchConditionVC *vc = [[QiangdanSearchConditionVC alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
